package com.ruoyi.user.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author houyong
 */
public class ServerChargeUtil {

    ServerChargeUtil() {
    }

    /**
     * 支付手续费
     *
     * @param amount
     * @return
     */
    public static BigDecimal serverCharge(BigDecimal amount) {
        return amount.multiply(PayChannel.RATE).setScale(2, RoundingMode.HALF_DOWN);

    }

    /**
     * 支付手续费
     *
     * @param amount
     * @return
     */
    public static BigDecimal unionCashierServerCharge(BigDecimal amount) {
        return amount.multiply(PayChannel.RATE).setScale(2, RoundingMode.HALF_DOWN);
    }

    /**
     * 退还手续费
     *
     * @param amount
     * @return
     */
    public static BigDecimal refundCharge(BigDecimal amount) {
        return amount.multiply(PayChannel.RATE).setScale(2, RoundingMode.HALF_EVEN);
    }

    public static BigDecimal bigDecimal(BigDecimal amount) {
        return amount.setScale(2, RoundingMode.HALF_UP);
    }


}
